package ${beanPackageName};

import java.sql.Timestamp;
import java.util.Map;
import java.util.HashMap;

import com.ai.acctcomp.po.ArrayDataContainer;
import com.ai.appframe2.common.AIException;
import com.ai.appframe2.common.DataContainerInterface;
import com.ai.appframe2.common.DataType;
import com.ai.appframe2.common.ObjectType;
import com.ai.appframe2.common.ServiceManager;
import ${ivaluePackageName}.${ivalueClassName};

/**
* create by genbo tool, Don't modify!
* @auth genbo-tool
*/
public class ${beanClassName} extends ArrayDataContainer implements DataContainerInterface, ${ivalueClassName} {

	private static final long serialVersionUID = 1L;

	private static final int COLUMN_SIZE = ${allCols?size};

	private static String m_boName = "${beanPackageName}.${boName}";

<#list allCols as column>
	public final static String S_${column.firstUpperName} = "${column.name}";
</#list>

<#list allCols as column>
	public final static int IDX_${column.firstUpperName} = ${column_index};
</#list>

	private static String[] INDEX_NAME = new String[COLUMN_SIZE];
    private static Map<String, Integer> NAME_INDEX = new HashMap<>(COLUMN_SIZE);
	public static ObjectType S_TYPE = null;

	static {
		try {
			S_TYPE = ServiceManager.getObjectTypeFactory().getInstance(m_boName);

<#list allCols as column>
			INDEX_NAME[IDX_${column.firstUpperName}] = S_${column.firstUpperName};
</#list>

<#list allCols as column>
            NAME_INDEX.put(S_${column.firstUpperName}, IDX_${column.firstUpperName});
</#list>

		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public ${beanClassName}() throws AIException {
		super(S_TYPE, COLUMN_SIZE);
	}

	public static ObjectType getObjectTypeStatic() throws AIException {
		return S_TYPE;
	}

	@Override
	public void setObjectType(ObjectType value) throws AIException {
		// 此种数据容器不能重置业务对象类型
		throw new AIException("Cannot reset ObjectType");
	}

    @Override
    protected int getColumnIndex(String name) {
        Integer index = NAME_INDEX.get(name);
        if (index == null) {
            throw new RuntimeException("Don't support this property:" + name);
        } else {
            return index;
        }
    }

    @Override
    protected String getIndexColumnName(int index) {
        return INDEX_NAME[index];
    }

<#list allCols as column>
	public void init${column.firstUpperName}(${column.javaType} value) {
		this.initProperty(IDX_${column.firstUpperName}, value);
	}

	@Override
	public void set${column.firstUpperName}(${column.javaType} value) {
		this.set(IDX_${column.firstUpperName}, value);
	}

	public void set${column.firstUpperName}Null() {
		this.set(IDX_${column.firstUpperName}, null);
	}

	@Override
	public ${column.javaType} get${column.firstUpperName}() {
		return DataType.getAs${column.dataType}(this.get(IDX_${column.firstUpperName}));

	}

	public ${column.javaType} get${column.firstUpperName}InitialValue() {
		return DataType.getAs${column.dataType}(this.getOldObj(IDX_${column.firstUpperName}));
	}

</#list>
}

